<template>
    <block v-if="scene == 1154">
    	<pyq-open-chunk></pyq-open-chunk>
    </block>
    <block v-else>
        <view class="pages col-3e">
            <view class="cardItem">
                <text class="cardTit fontBold font18">销售信息</text>
                <view class="item flex">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">楼盘地址</text>
                    </view>
                    <view class="lableCon col-primary" @click="toAddress">
                        <text class="bg icon-map"></text>
                        {{product.city}}{{product.area}}{{product.address}}
                    </view>
                </view>
                <view class="item flex" v-if="product.sell_submit_house">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">交房时间</text>
                    </view>
                    <view class="lableCon col-3e">{{product.sell_submit_house}}</view>
                </view>
            </view>
            <view class="cardItem">
                <text class="cardTit fontBold font18">基本信息</text>
                <view class="item flex" v-if="product.base_alias">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">别名</text>
                    </view>
                    <view class="lableCon col-3e">{{product.base_alias}}</view>
                </view>
                <view class="item flex">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">楼盘类型</text>
                    </view>
                    <view class="lableCon col-3e">{{product.base_type_display}}</view>
                </view>
                <view class="item flex" v-if="product.base_year">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">产权年限</text>
                    </view>
                    <view class="lableCon col-3e">{{product.base_year}}年</view>
                </view>
                <view class="item flex" v-if="product.community_build_company">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">开发商</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_build_company}}</view>
                </view>
                <view class="item flex" v-if="product.community_property_company">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">物业公司</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_property_company}}</view>
                </view>
                <view class="item flex" v-if="product.community_employ_size">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">占地面积</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_employ_size}}m²</view>
                </view>
                <view class="item flex" v-if="product.current_employ_size">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">本期占地面积</text>
                    </view>
                    <view class="lableCon col-3e">{{product.current_employ_size}}m²</view>
                </view>
                <view class="item flex" v-if="product.community_build_size">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">建筑面积</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_build_size}}m²</view>
                </view>
                <view class="item flex" v-if="product.current_build_size">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">本期建筑面积</text>
                    </view>
                    <view class="lableCon col-3e">{{product.current_build_size}}m²</view>
                </view>
                <view class="item flex" v-if="product.community_building">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">楼栋数</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_building}}</view>
                </view>
                <view class="item flex" v-if="product.community_house">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">总户数</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_house}}户</view>
                </view>
                <view class="item flex" v-if="product.floor_height">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">楼盘层高</text>
                    </view>
                    <view class="lableCon col-3e">{{product.floor_height}}</view>
                </view>
                
                <view class="item flex" v-if="product.community_plant">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">绿化率</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_plant}}%</view>
                </view>
                <view class="item flex" v-if="product.community_bulk">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">容积率</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_bulk}}</view>
                </view>
                <view class="item flex" v-if="product.community_car">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">车位数</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_car}}</view>
                </view>
                <view class="item flex" v-if="product.community_car_house">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">车位比</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_car_house}}</view>
                </view>
                <view class="item flex" v-if="product.community_th">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">梯户比</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_th}}</view>
                </view>
                <view class="item flex" v-if="product.community_property_cost">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">物业费用</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_property_cost}}元/m²</view>
                </view>
                <view class="item flex" v-if="product.community_warm_display">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">供暖</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_warm_display}}</view>
                </view>
                <view class="item flex" v-if="product.community_water_display">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">供水</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_water_display}}</view>
                </view>
                <view class="item flex" v-if="product.community_ele_display">
                    <view class="lableTit col-grey flex">
                        <text class="title txtJustify">供电</text>
                    </view>
                    <view class="lableCon col-3e">{{product.community_ele_display}}</view>
                </view>
            </view>
            <view class="cardItem">
                <text class="cardTit fontBold font18">楼盘简介</text>
                <view class="item desc">{{product.content}}</view>
            </view>

            <u-gap height="40" bg-color="#fff"></u-gap>

			<!-- <bind-seller-bottom-bar :detail="recommendAdviser" v-if="recommendAdviser&&recommendAdviser.avatar_url"></bind-seller-bottom-bar> -->

            <!-- <share-btn :display="scrollAnimate"></share-btn> -->
        </view>
    </block>
</template>
<script>
    import { mapState, mapActions } from 'pinia';
    import { useConfigStore, useUserInfoStore } from '@/store/index';
    import { isBoolean } from '@/common/common';
    import { houseDeatilMsg } from '@/common/api';
    // import { dispatchClient } from '@/common/api-adviser';
    // import { getSellerInfoById } from '@/common/api/adviser';

	export default {
		data() {
			return {
                productId: null,
				product: {},
                start_time: 0,
                title: '',
                share: false,
                scrollAnimate: false,
                recommendAdviser: {}
			}
		},
        computed:{
            ...mapState(useConfigStore, ['scene', 'puid']),
            ...mapState(useUserInfoStore, ['userInfo'])
        },
        onShareAppMessage(res) {
            return {
                title: `【${this.product.title}】线上售楼处在这儿`,
                path: `/pages/product/estate-message/index?productId=${this.productId}&share=true&puid=${this.userInfo.id}&title=${this.product.title}&prepage=楼盘详细信息-${this.productId}-${this.product.title}`,
            }
        },
        //#ifdef MP-WEIXIN
        onShareTimeline() {
            return {
                title: `【${this.product.title}】线上售楼处在这儿`,
                query: `productId=${this.productId}&share=true&puid=${this.userInfo.id}&title=${this.product.title}&prepage=楼盘详细信息-${this.productId}-${this.product.title}`
            }
        },
        //#endif
		onLoad(options) {
            let { productId='', puid='', title='', share=false } = options;
            
            //朋友圈进入小程序快照场景
            if(this.scene == 1154) return;
            
            this.productId = productId&&productId!=='undefined'?productId:'';
            this.title = title&&title!=='undefined'?title:'';
            this.share = isBoolean(share);
            this.start_time = (new Date()).getTime();
            if(puid&&puid!=='undefined') {
                this.setPuid(puid)
            }

            let that = this;
			if(this.productId){
				uni.$check_and_login(function () {
					that.init();
				})
			}
		},
       
		methods: {
            ...mapActions(useConfigStore, ['setPuid']),
			//初始化数据
			async init(){
				uni.showLoading({
					title: '数据加载中',
					mask: true
				})

                let detailRes = await houseDeatilMsg(this.productId);

                if(detailRes.status == 0) {
                    let { base, product } = detailRes.detail;
                    this.product = {...base, ...product};
                    uni.hideLoading()
                }else {
                    uni.hideLoading();
                    uni.$u.toast(detailRes.detail)
                }

                //绑定客户
                // await dispatchClient({
                //     share: this.share,
                //     puid: this.puid,
                //     pid: this.productId
                // });

                //根据顾问ID获取被绑定的顾问信息
                // if(this.puid && this.puid !== this.userInfo.id) {
                //     let sellInfoRes = await getSellerInfoById({id:this.puid, productId: this.productId});
                //     if(sellInfoRes.status === 0) {
                //         if(sellInfoRes.detail.product_id && sellInfoRes.detail.product_id == this.productId) {
                //             this.recommendAdviser = sellInfoRes.detail;
                //         }
                //     }
                // }
			},

            //跳转地图
            toAddress(){
              if(this.product.lat > 0 && this.product.lng > 0){
                   uni.openLocation({
                     latitude: this.product.lat,
                     longitude: this.product.lng,
                     success: function () {
                     }
                   });
                }
            }
		}
	}
</script>

<style lang="scss" scoped>
	.pages{
        line-height: 1;
		min-height: 100vh;
        overflow: hidden;
        padding: 0rpx 28rpx;
		background-color: #FFFFFF;
        .cardItem{
            margin-top: 30rpx;
            .cardTit{
                display: block;
                margin-bottom: 30rpx;
            }
        }
        .item{
            align-items: flex-start;
            justify-content: flex-start;
            margin-bottom: 20rpx;
            .lableTit{
                .title{
                    margin-right: 10rpx;
                    width: 140rpx;
                }
            }
            .lableCon{
                width: calc(100% - 185rpx);
                margin-left: 20rpx;
                line-height: 1.2;
                .icon-map{
                    display: inline-block;
                    margin-right: 10rpx;
                    width: 22rpx;
                    height: 28rpx;
                    background-image: url("https://image.srea.org.cn/xcx/icon/icon-map-grey.png");
                }
            }
        }
        .desc{
            white-space: pre-wrap;
            margin-bottom: 30rpx;
            line-height: 1.5;
        }
	}
</style>
